/*
 * @Author       : wfl
 * @LastEditors: qiye
 * @description  :
 * @updateInfo   :
 * @Date         : 2023-03-02 09:54:41
 * @LastEditTime: 2024-02-04 19:07:25
 */
import pinia from '@g/store'
import router from '@g/router'
import ElementPlus from 'element-plus'
import '@g/utils/system.copyright'
// 加载 svg 图标
import 'virtual:svg-icons-register'
import { computedLocalStorageSize } from '@g/utils/computed'

/** 动态表单 begin */
import vForm from 'iking-form'
import 'iking-form/dist/designer.style.css'
// import vForm from 'mo-form'
// import 'mo-form/dist/designer.style.css'
/** 动态表单 end */

import App from './App.vue'
import { useI18n } from '@/locales'

import 'iking-web-ui/dist/style.css'
// 全局样式
import 'uno.css'
import '@/assets/styles/globals.scss'
import '@/assets/iconfont-flow/iconfont.css'
// 注册图标
import '@/assets/svg/iconfont'

import DynamicIkDialogApprove from '@/global/components/BusinessCom/ApproveDetail/ApprovalDetail.vue'
import IkTinymce from '@/global/components/BaseCom/IkCodeEditor/IkTinymce.vue'
import IkPageFull from '@/global/components/LayoutCom/IkPageFull/index.vue'

const startApp = () => {
  const app = createApp(App)
  app.use(ElementPlus)
  app.use(pinia)
  app.use(router)
  app.use(vForm)
  // app.use(IkingWebUI)

  useI18n(app)
  reginterDiective(app)
  registerComponent(app)

  errorLog(app)
  computedLocalStorageSize()

  /** 提供给动态表单引用的全局组件 begin */
  app.component('DynamicIkDialogApprove', DynamicIkDialogApprove)
  app.component('DynamicIkTinymce', IkTinymce)
  app.component('DynamicIkPageFull', IkPageFull)
  /** 提供给动态表单引用的全局组件 begin */

  // 监听卸载操作
  window.addEventListener('unmount', () => {
    app.unmount()
  })

  const mount = () => {
    app.mount('#app')
  }

  return {
    app,
    mount
  }
}
export default startApp
